<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 17-5-25
 * Time: 下午5:04
 */

namespace common\components\gps;


use common\models\CarGpsOrder;
use yii\base\Component;
use yii\base\ErrorException;

/**
 * Class Gps
 * @package common\components\gps
 *
 * @property CarGpsOrder $order
 */
abstract class Gps extends Component
{
    protected $_order;

    public function setOrder($order)
    {
        $this->_order = $order;
    }

    public function getOrder()
    {
        return $this->_order;
    }

    protected function checkOrder()
    {
        if (!$this->order){
            throw new ErrorException('没有找到订单实例,请先添加gps订单', 1043);
        }
    }

    /**
     * 高德由经纬度获取地图位置
     * @param $j
     * @param $w
     * @return string
     */
    public static function getMapLocationByGaoDe($j, $w)
    {
        return "http://uri.amap.com/marker?position={$j},{$w}";
    }
}